package gui;

import javax.swing.Timer;

import statics.Constants;

public class WalkHandler {

	private Player p;
	private PlayPanel pp;
	private WalkActionListener mwl;
	private Map m;
	private Timer walk;
	public boolean isWalking;
	
	public WalkHandler(Player p, PlayPanel pp, Map m){
		this.p = p;
		this.pp = pp;
		this.mwl = new WalkActionListener(this);
		this.m = m;
		
		walk = new Timer(Constants.FPS, mwl);
	}
	
	public void stopWalking() {
		walk.stop();
		isWalking = false;
	}
	
	public void walk(char dir) {
		switch(dir){
			case 'z' : mwl.setInverse(false); break;
			case 's' : mwl.setInverse(true); break;
		}
		
		if(!isWalking){
			walk.start();
			isWalking = true;
		}
	}

	public int getMX() {
		return pp.getMX();
	}

	public int getMY() {
		return pp.getMY();
	}

	public int getPX() {
		return p.getX();
	}

	public int getPY() {
		return p.getY();
	}

	public int getPlayerSpeed() {
		return p.getSpeed();
	}

	public void moveX(int px) {
		p.moveX(px);
	}

	public void moveY(int py) {
		p.moveY(py);
	}

	public void repaint() {
		pp.repaint();
	}
	
	public Map getMap(){
		return pp.getMap();
	}
	
}
